package com.example.mysqlsearchdemo.repositories;

import com.example.mysqlsearchdemo.entities.Prize;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface PrizeRepository extends JpaRepository<Prize, Long> {

    @Query(nativeQuery = true,
            value = "select p.*,u.user_name from `prize` as p left join `user` as u on p.user_id = u.id ",
            countQuery = "select 1 from prize")
    Page<Prize> findAllIsMy(Pageable pageable);
}
